enum CheckpointControllerState{ PlayerAtCheckPoint, PlayerMoving}

var currentState : CheckpointControllerState = CheckpointControllerState.PlayerMoving;

var checkpoints : Checkpoint[];
var currentCheckpoint : Checkpoint;

function Start(){
  //gameobject = GameObject.Find("Checkpoints");
  //Debug.Log(gameobject);
   // (ScriptName is the name of the javascript file)
  //checkpoints = gameobject.GetComponentsInChildren(Checkpoint);
  //Debug.Log(gameobject.GetComponentsInChildren(Checkpoint));
  checkpoints = FindObjectsOfType(Checkpoint) as Checkpoint[];
  /*for (var ch : Checkpoint in checkpoints)
		{
			if (tr != SplineParent.transform)
				tempTransformsArray.Add(tr);
		}
  var tempTransformsArray = new ArrayList();	
  		tempTransformsArray.Sort(new NameComparer());
		ret = Array(tempTransformsArray);*/
}

function setMotionState(stateArr){
  currentCheckpoint = stateArr[1];
  if(stateArr[0] == "PlayerHere")
    currentState = CheckpointControllerState.PlayerAtCheckPoint;
  else{
  if(stateArr[0] == "PlayerNotHere"){
    currentState = CheckpointControllerState.PlayerMoving;
  }}
   
}

function getState(){
  return currentState;
  }
  
function getPauseSetting(){
  return currentCheckpoint.EnablePause;
}

function StartMotion(){
  currentState = CheckpointControllerState.PlayerMoving;
  if(currentCheckpoint != null){
    currentCheckpoint.StartMotion();
    }
}

function GetLaunchMngr(){
  return currentCheckpoint.lm;
}
function Update () {
  
  for (var ch : Checkpoint in checkpoints){
    if(ch.getState() == CheckpointState.PlayerHere){
      currentState = CheckpointControllerState.PlayerAtCheckPoint;
    }
      
  }
}